Functions List


Coordinate Systems


xyz

The function xyz defines a position in space specified by its Cartesian coordinates x, y, and z.

Parameters:

x - Coordinate value for x
y - Coordinate value for y
z - Coordinate value for z

Syntax:

(xyz x y z)

Example:

> (xyz 1 2 3)
#<xyz 1 2 3>

> (xyz (* 2 3) (+ 4 1) (- 6 2))
#<xyz 6 5 4>



cx

The function cx returns the x coordinate of a given point.

Parameters:

p – Point from which to extract the x coordinate

Syntax:

(cx p)

Example:

> (cx (xyz 1 2 3))
1

> (cx (xyz (* 2 3) (+ 4 1) (- 6 2)))
6



cy

The function cy returns the y coordinate of a given point.

Parameters:

p – Point from which to extract the y coordinate

Syntax:

(cy p)

Example:

> (cy (xyz 1 2 3))
2

> (cy (xyz (* 2 3) (+ 4 1) (- 6 2)))
5



cz

The function cz returns the z coordinate of a given point.

Parameters:

p – Point from which to extract the z coordinate

Syntax:

(cz p)

Example:

> (cz (xyz 1 2 3))
3

> (cz (xyz (* 2 3) (+ 4 1) (- 6 2)))
4



x

The function x defines a position in space specified only by its x coordinate, meaning the position will be located along the X axis. The remaining coordinates are null.

Parameters:

n – Coordinate value for x

Syntax:

(x n)

Example:

> (x 5)
#<xyz:5 0 0>



y

The function y defines a position in space specified only by its y coordinate, meaning the position will be located along the Y axis. The remaining coordinates are null.

Parameters:

n – Coordinate value for y

Syntax:

(y n)

Example:

> (y 3)
#<xyz:0 3 0>



z

The function z defines a position in space specified only by its z coordinate, meaning the position will be located along the Z axis. The remaining coordinates are null.

Parameters:

n – Coordinate value for z

Syntax:

(z n)

Example:

> (z 10)
#<xyz:0 0 10>



xy

The function xy defines a position in space specified by its x and y coordinates, meaning the position will be located on the XY plane. The z coordinate is null.

Parameters:

x – Coordinate value for x
y - Coordinate value for y

Syntax:

(xy x y)

Example:

> (xy 2 5)
#<xyz:2 5 0>

> (xy 0 0)
#<xyz:0 0 0>



xz

The function xz defines a position in space specified by its x and z coordinates, meaning the position will be located on the XZ plane. The y coordinate is null.

Parameters:

x – Coordinate value for x
z - Coordinate value for z

Syntax:

(xz x z)

Example:

> (xz 1 8)
#<xyz:1 0 8>



yz

The function yz defines a position in space specified by its y and z coordinates, meaning the position will be located on the YZ plane. The x coordinate is null.

Parameters:

y – Coordinate value for y
z - Coordinate value for z

Syntax:

(yz y z)

Example:

> (yz 3 7)
#<xyz:0 3 7>



+xyz

Given a position in space, the function +xyz will define a new position by applying a translation vector to all its coordinates.

Parameters:

p – Original point in space
dx – Translation value for the x coordinate
dy – Translation value for the y coordinate
dz – Translation value for the z coordinate

Syntax:

(+xyz p dx dy dz)

Example:

> (+xyz (xyz 0 0 0) 1 2 3)
#<xyz:1 2 3>

> (+xyz (xyz 1 2 3) 4 5 6)
#<xyz:5 7 9>



+x

Given a position in space, the function +x will define a new position by applying a translation vector to the x coordinate only. The y and z coordinates of the original position remain unaltered.

Parameters:

p – Original point in space
dx – Translation value for the x coordinate

Syntax:

(+x p dx)

Example:

> (+x (xyz 0 0 0) 5))
#<xyz:5 0 0>



+y

Given a position in space, the function +y will define a new position by applying a translation vector to the y coordinate only. The x and z coordinates of the original position remain unaltered.

Parameters:

p – Original point in space
dy – Translation value for the y coordinate

Syntax:

(+y p dy)

Example:

> (+y (xyz 1 2 3) 5))
#<xyz:1 7 3>



+z

Given a position in space, the function +z will define a new position by applying a translation vector to the z coordinate only. The x and y coordinates of the original position remain unaltered.

Parameters:

p – Original point in space
dz – Translation value for the z coordinate

Syntax:

(+z p dz)

Example:

> (+z (xyz 1 2 3) 3))
#<xyz:1 2 6>



+xy

Given a position in space, the function +xy will define a new position by applying a translation vector to its x and y coordinates. The z coordinate of the original position remains unaltered.

Parameters:

p – Original point in space
dx – Translation value for the x coordinate
dy – Translation value for the y coordinate

Syntax:

(+xy p dx dy)

Example:

> (+xy (xyz 1 2 3) 1 3))
#<xyz:2 5 3>



+xz

Given a position in space, the function +xz will define a new position by applying a translation vector to its x and z coordinates. The y coordinate of the original position remains unaltered.

Parameters:

p – Original point in space
dx – Translation value for the x coordinate
dz – Translation value for the z coordinate

Syntax:

(+xz p dx dz)

Example:

> (+xz (xyz 1 2 3) 1 5))
#<xyz:2 2 8>



+yz

Given a position in space, the function +yz will define a new position by applying a translation vector to its y and z coordinates. The x coordinate of the original position remains unaltered.

Parameters:

p – Original point in space
dy – Translation value for the y coordinate
dz – Translation value for the z coordinate

Syntax:

(+yz p dy dz)

Example:

> (+yz (xyz 2 1 5) 1 2))
#<xyz:2 2 7>



pol

The function pol defines a position in space specified by its polar coordinates, i.e., specified by a radius and an angle with the X axis. The height of the position will be null.

Parameters:

rho – Polar radius
phi – Polar angle with the X axis

Syntax:

(pol rho phi)

Example:

> (pol 1 0)
#<xyz 1 0 0>

> (pol (sqrt 2) (/ pi 4))
#<xyz 1.0000000000000002 1.0 0>

> (pol 1 (/ pi 2))
#<xyz 6.123233995736766e-017 1.0 0>

> (pol 1 pi)
#<xyz -1.0 1.2246467991473532e-016 0>



pol-rho

Given a position in space, the function pol-rho returns the distance of that position to the UCS origin.

Parameters:

p – Position in space

Syntax:

(pol-rho p)

Example:

> (pol-rho (pol 10 (/ pi 3)))
10.0

> (pol-rho (xyz 1 2 3))
2.23606797749979



pol-phi

Given a position in space, the function pol-phi returns the angle value of that position with the X axis.

Parameters:

p – Position in space

Syntax:

(pol-phi p)

Example:

> (pol-phi (pol 10 (/ pi 3)))
1.0471975511965976

> (pol-phi (xyz 1 2 3))
1.1071487177940904



+pol

Given a position in space, the function +pol will define a new position by applying a translation vector specified by its intensity and direction. The z coordinate remains unaltered.

Parameters:

p – Position in space
drho – Vector intensity
dphi – Vector direction

Syntax:

(+pol p drho dphi)

Example:

> (+pol (xy 1 2) (sqrt 2) (/ pi 4))
#<xyz 2.0 3.0 0>

> (+pol (xy 1 2) 1 0)
#<xyz 2 2 0>

> (+pol (xy 1 2) 1 (/ pi 2))
#<xyz 1.0 3.0 0>



cyl

The function cyl defines a position in space specified by its cylindrical coordinates, i.e., a radius, an angle with the X axis and a height value.

Parameters:

rho – Polar radius
phi – Polar angle with the X axis
z – Height value

Syntax:

(cyl rho phi z)

Example:

> (cyl 5 0 10)
#<xyz:5 0 10>



cyl-rho

Given a position in space, the function cyl-rho returns the distance of that position to the UCS origin. If the position is specified in cylindrical coordinates it returns the rho component.

Parameters:

p – Position in space

Syntax:

(cyl-rho p)

Example:

> (cyl-rho (xyz 1 5 8))
5.0990195135927845
> (cyl-rho (cyl 5 pi/2 8))
5.0
> (cyl-rho (pol 2 pi/3))
2.0



cyl-phi

Given a position in space, the function cyl-phi returns the angle value of that position with the X axis. If the position is specified in cylindrical coordinates it returns the phi component.

Parameters:

p – Position in space

Syntax:

(cyl-phi p)

Example:

> (cyl-phi (xyz 1 5 8))
1.373400766945016
> (cyl-phi (cyl 5 pi/2 8))
1.5707963267948966
> (cyl-phi (cyl 5 1.7 8))
1.7



cyl-z

Given a position in space, the function cyl-z returns the height value of that position. If the position is specified in cylindrical coordinates it returns the z component.

Parameters:

p – Position in space

Syntax:

(cyl-z p)

Example:

> (cyl-z (xyz 0 5 3))
3
> (cyl-z (cyl 4 pi/6 -5))
-5
> (cyl-z (pol 10 pi/4))
0



+cyl

Given a position in space, the function +cyl) will define a new position by applying a translation vector specified by its intensity, direction and height.

Parameters:

p – Original position in space
drho – Vector intensity
dphi – Vector direction
dz – Height change

Syntax:

(+cyl p drho dphi dz)

Example:

> (+cyl (xyz 1 2 3) 3 pi/6 5)
#<xyz:3.598076211353316 3.5 8>



sph

The function sph defines a position in space specified in spherical coordinates, i.e., a radius, the longitude (azimuth) and polar angle (zenith).

Parameters:

rho – Radius
phi – Longitude
psi – Polar angle

Syntax:

(sph rho phi psi)

Example:

> (sph (sqrt 3) pi/4 (atan (sqrt 2)))
#<xyz:1.0 0.9... 0.9...>



sph-rho

Given a position in space, the function sph-rho returns the distance of that position to the UCS origin. If the position is specified in spherical coordinates it returns the rho component.

Parameters:

p - Position in space

Syntax:

(sph-rho p)

Example:

> (sph-rho (sph 2 pi/3 pi/4))
2.0
> (sph-rho (cyl 10 pi 5))
11.180339887498949



sph-phi

Given a position in space, the function sph-phi returns the angle value of that position with the X axis. If the position is specified in spherical coordinates it returns the phi component.

Parameters:

p - Position in space

Syntax:

(sph-phi p)

Example:

> (sph-phi (xyz 2 2 10))
0.7853981633974483
> (sph-phi (sph 2 pi pi/6))
3.141592653589793
> (sph-phi (cyl 5 1.2 -5))
1.2



sph-spi

Given a position in space, the function sph-psi returns the polar angle of that position, i.e., the angle measured from the azimuth reference direction to the orthogonal projection of the line segment origin-position on the reference plane. If the position is specified in spherical coordinates it returns the psi component.

Parameters:

p - Position in space

Syntax:

(sph-psi p)

Example:

> (sph-psi (sph 5 pi/2 pi/4))
0.7853981633974483
> (sph-psi (sph 10 0 5.2))
1.0831853071795863
> (sph-psi (cyl 4.2 -pi/3 3.1))
0.9349579032711515



+sph

Given a position in space, the function +sph will define a new position by applying a translation vector specified by its intensity, longitudinal direction and polar direction.

Parameters:

p – Original position in space
drho – Vector intensity
dphi – Longitudinal direction
dpsi – Polar direction

Syntax:

(+sph p drho dphi dpsi)

Example:

> (+sph (xyz 1 2 3) 4 pi/4 pi/3)
#<xyz:3.4494897427831783 4.449489742783178 5.0>



+rho

Given a position in space, the function +rho will add a radial distance to that specified position.

Parameters:

p - Original position
rho - Radial distance

Syntax:

(+rho p rho)

Example:

> (+rho (xyz 1 2 0) 5)
#<xyz:3.2360679774997902 6.47213595499958 0>
> (+rho (cyl 5 pi/4 10) 5)
#<xyz:7.0710678118654755 7.071067811865475 10>
> (+rho (cyl 5 0 10) 2)
#<xyz:7 0 10>



+phi

Given a position in space, the function +phi will add a polar angle to that specified position.

Parameters:

p - Original position
phi - Polar angle

Syntax:

(+phi p phi)

Example:

> (+psi (sph 5 0 pi/4) pi/3)
#<xyz:4.8296291314453415 0.0 -1.2940952255126033>
> (+psi (cyl 5 0 2) pi/2)
#<xyz:2.0000000000000004 0 -5.0>



+psi

Given a position in space, the function +psi will add an azimuth angle to that specified position.

Parameters:

p - Original position
psi - Azimuth angle

Syntax:

(+psi p psi)

Example:

> (+psi (cyl 5 0 2) pi/2)
#<xyz:2.0000000000000004 0 -5.0>
> (+psi (sph 10 0 pi) pi)
#<xyz:-2.4492935982947065e-015 -0.0 10.0>
> (+psi (xyz 0 0 0) pi/2)
#<xyz:0 0 0>
> (+psi (xyz 1 1 0) pi/4)
#<xyz:0.7071067811865477 0.7071067811865476 -1.0>



roundc

The function roundc rounds the coordinates of a specified position up or down depending on the decimal value.

Parameters:

p - Position

Syntax:

(roundc p)

Example:

> (roundc (xyz 1.5 2.2 0.1))
#<xyz:2.0 2.0 0.0>
> (roundc (xyz 1.00000002 2.00521 0.0000015))
#<xyz:1.0 2.0 0.0>



=c?

The function =c? tests is two given coordinates are coincidental, returning #t if they are and #f if they are not. Be aware that due to round off errors two positions might not be tested for #t even when they appear to be coincidental (see last example). For that make sure to use the function roundc first.

Parameters:

p1 - First position
p2 - Second position

Syntax:

(=c? p1 p2)
(=c? (roundc p1) (roundcp2))

Example:

> (=c? (xyz 5 6 0) (xy 5 6))
#t
> (=c? (xyz 3 0 5) (xyz 0 -8 7))
#f
> (=c? (cyl 5.0 pi/2 0.0) (pol 5.0 pi/2))
#t
> (=c? (xy 0 5) (pol 5 pi/2))
#f
> (=c? (roundc (xy 0 5)) (roundc (pol 5 pi/2)))
#t



xyz-on

The function xyz-on sets a new UCS by specifying the origin position and both the X and Y axes. The Y axis doesn't have to be perpendicular to the X axis.

Parameters:

o - Origin point
x - X axis
y - Y axis

Syntax:

(xyz-on o x y)

Example:

> (rectangle (xyz-on (xyz 0 0 0) (uxy) (uy)) 10 5)
#<rectangle 0>



xyz-on-z-rot

The function xyz-on-z-rot rotates the UCS by a specified angle along the the Z axis. The X and Y axes remain perpendicular to each other.

Parameters:

p - Origin point
a - Rotation angle

Syntax:

(xyz-on-z-rot p a)

Example:

>(rectangle (xyz-on-z-rot (xyz 0 0 0) pi/4) 10 5)
#<rectangle 0>
Top